package cn.achao.csr.base.constant.enums;

import cn.achao.csr.base.exception.BusinessException;
import cn.achao.csr.base.utils.ThrowUtils;
import lombok.Getter;

/**
 * @Author: achao
 **/
@Getter
public enum SysSourceEnum {

    CSR_AUTH("csr-auth", "鉴权服务"),
    CSR_GATEWAY("csr-gateway", "网关服务"),
    CSR_SEQUENCE("csr-sequence", "序列服务"),
    CSR_SYSTEM("csr-system", "系统服务"),
    CSR_ZFB("csr-zfb", "支付宝服务"),
    CSR_CHAT("csr-chat", "聊天服务"),
    CSR_FILE("csr-file", "文件服务"),
    CSR_API("csr-openapi", "第三方调用服务"),
    ;

    SysSourceEnum(String sysCode, String sysName) {
        this.sysCode = sysCode;
        this.sysName = sysName;
    }


    private final String sysCode;

    private final String sysName;

    public static SysSourceEnum getBySysCode(String sysCode) {
        for (SysSourceEnum value : values()) {
            if (value.getSysCode().equals(sysCode)) {
                return value;
            }
        }
        ThrowUtils.throwIf(BusinessException.fail("系统来源异常，记录ip", sysCode));
        return null;
    }
}
